﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Job.Entity;
using Job.Logic.BaseContent;

namespace Job.Web.userControls.Admin
{
    public partial class AdminPassword1 : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btSave_Click(object sender, EventArgs e)
        {
            string oldPassword = tbOldPassword.Text;
            string newPassword = tbNewPassword1.Text;

            MySession session = new MySession();
            int userId = session.GetAdminUserFromSession().UserId;
            JobUser info = new AdminUserLogic().GetDetailById(userId);

            if (!info.Password.Equals(oldPassword))
            {
                Page.RegisterClientScriptBlock("", "<script>alert('旧密码不正确！')</script>");
            }
            else
            {
                info.Password = newPassword;
                new AdminUserLogic().UpdatePassword(info);
                Page.RegisterClientScriptBlock("", "<script>alert('密码修改成功，请牢记新密码！')</script>");
            }
        }
    }
}